package com.geekaca.d4.d3;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class TestDateTime {
    /**
     * 日期时间
     */


    public static void main(String[] args) {
        LocalDateTime nowDateTime = LocalDateTime.now();
        System.out.println("当前时间: " + nowDateTime);
        System.out.println(nowDateTime.getYear());
        System.out.println(nowDateTime.getNano()); // 纳秒
        System.out.println(nowDateTime.getDayOfYear());

        DayOfWeek dayOfWeek = nowDateTime.getDayOfWeek();
        System.out.println("day of week: " + dayOfWeek);
        System.out.println(dayOfWeek.getValue());
        DayOfWeek minus = dayOfWeek.minus(10);
        System.out.println(minus);

        /**f
         * LocalDateTime -> LocalDateTime
         * LocalDateTime -> LocalTime
         */

        LocalDate localDate = nowDateTime.toLocalDate();
        LocalTime localTime = nowDateTime.toLocalTime();

        System.out.println("日期: " + localDate);
        System.out.println("时间: " + localTime);

    }
}
